#include <iostream>

template <typename T>  // 父类模版化
class Singleton
{
public:
    static T &getInstance()
    {
        static T instance;
        return instance;
    }
};

class Test : public Singleton<Test>  // 奇异递归
{
public:
    friend Singleton<Test>;  // 声明友元
    void show()
    {
        std::cout << "helloworld" << std::endl;
    }
private:
    Test() {}
};

int main()
{
    Test::getInstance().show();
    return 0;
}
